#include <iostream>
#include "Game.h"
#include "XMLParser.h"

using namespace std;


/**
 * Loads all Class information for the game.
 * @see GetConfig::GetConfig()
 * @see GetConfig::addATTROption()
 * @see GetConfig::readClassConfigFile
 * @param void
 * @return void
 */
void Game::loadClassInformation()
{
	XMLParser appConfig(GAME_LOADCONFIG_CLASS_ROOTELEM, GAME_LOADCONFIG_CLASS_FIRSTELEM, GAME_LOADCONFIG_CLASS_SECDELEM);

	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR1);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR2);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR3);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR4);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR5);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR6);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR7);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR8);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR9);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR10);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR11);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR12);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR13);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR14);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR15);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR16);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR17);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR18);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR19);
	appConfig.addATTROption(GAME_LOADCONFIG_CLASS_ATTR20);
	appConfig.readClassConfigFile(GAME_LOADCONFIG_CLASS_FILENAME, m_classes);
}


/**
 * Prints out information about all the Classes in the Game
 * @see Class::print()
 * @param void
 * @return void
 */
void Game::showClassInformation()
{
	for (unsigned int i = 0; i < m_classes.size(); ++i)
	{
		m_classes[i]->print();
	}
}


/**
 * Deletes all classes in the Game
 * @param void
 * @return void
 */
void Game::freeClassInformation()
{
	if (m_classes.size() == 0)
	{
		cout << "No classes information available." << endl;
	}
	else
	{
		for (unsigned int i = 0; i < m_classes.size(); ++i)
		{
			Class* delClass;

			delClass = m_classes[i];
			delete delClass;
		}
		m_classes.resize(0);
	}
}
